home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / BORL_TIP / TI100 / TI552.ASC < prev    next >
Text File  |  1992-08-12  |  21KB  |  859 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.   PRODUCT  :  Turbo Pascal                           NUMBER  :  552
  9.   VERSION  :  1.0
  10.        OS  :  Windows
  11.      DATE  :  August 12, 1992                         PAGE  :  1/13
  12.  
  13.     TITLE  :  Unit for Printing in Windows
  14.  
  15.  
  16.  
  17.  
  18.   {***********************************************}
  19.   {                                               }
  20.   {   Turbo Pascal for Windows                    }
  21.   {   WinPrint Unit                               }
  22.   {   Printer Module for use with OWL             }
  23.   {                                               }
  24.   {***********************************************}
  25.  
  26.   unit WinPrint;
  27.  
  28.   {$R PRINTER}
  29.   interface
  30.  
  31.   uses WinTypes, WinProcs, WObjects, Strings;
  32.  
  33.   type
  34.  
  35.   {/// TComboXferRec ///}
  36.     TComboXferRec = record
  37.       Strings: PStrCollection;
  38.       Selection: array[0..80] of Char;
  39.     end;
  40.  
  41.   { The transfer buffer used for the ComboBox in the TPrinterInfo
  42.     method SelectPrinter.  The fields, Strings and Selection, are
  43.     set up in the TPrinterInfo constructor Init.  The routine
  44.     GetCurrentPrinter is used to find current printing device which
  45.     is placed in Selection.  And the routine GetPrinterTypes is
  46.     used to fill out the Strings field.}
  47.  
  48.   {/// TAbortDialog ///}
  49.     PAbortDialog = ^TAbortDialog;
  50.     TAbortDialog = object(TWindow)
  51.      procedure SetUpWindow; virtual;
  52.      procedure WMCommand(var Msg: TMessage);
  53.        virtual wm_First + wm_Command;
  54.     end;
  55.  
  56.   { A descendant of TDialog used for the Abort Dialog seen when
  57.     printing is in progress. The AbortDialog is installed as a data
  58.     field of TPrinterInfo and is initialized and displayed in its
  59.     StartDoc method. The EndDoc method will Close the dialog if
  60.     necessary.}
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.   PRODUCT  :  Turbo Pascal                           NUMBER  :  552
  75.   VERSION  :  1.0
  76.        OS  :  Windows
  77.      DATE  :  August 12, 1992                         PAGE  :  2/13
  78.  
  79.     TITLE  :  Unit for Printing in Windows
  80.  
  81.  
  82.  
  83.  
  84.   {/// TPrinterInfo ///}
  85.     PPrinterInfo = ^TPrinterInfo;
  86.     TPrinterInfo = object
  87.       AbortDialog: PAbortDialog;
  88.       AbortDlg: HWnd;
  89.       AbortCallBackProc: TFarProc;
  90.       SelectDialog: PDialog;
  91.       SelectInfo: TComboXferRec;
  92.       Driver,
  93.       PrinterType,
  94.       Port: PChar;
  95.       DriverHandle: THandle;
  96.       PrintDC: HDC;
  97.       Error: Integer;
  98.       ExtDeviceMode: TExtDeviceMode;
  99.       DeviceModeVar: TDeviceMode;
  100.       RasterCaps: integer;
  101.       constructor Init;
  102.       destructor Done;
  103.       procedure SelectPrinter; virtual;
  104.       function GetPrinterDC: HDC;
  105.       procedure DeviceMode;
  106.       function BitMapCapable: boolean;
  107.       function BandingRequired: boolean;
  108.       procedure StartDoc(Name: PChar; AbortBox: Boolean); virtual;
  109.       procedure NewFrame; virtual;
  110.       procedure NextBand(var R:TRect); virtual;
  111.       procedure EndDoc; virtual;
  112.     end;
  113.  
  114.   { The controlling object for printing.  It is intended that this
  115.     object be initialized as a data field of a TWindow or
  116.     TApplication descendant. This printing object must be used OWL
  117.     based applications. The data fields are not supposed to be used
  118.     directly but may need to be accessed in special situations.
  119.     PrintDC and Error are the two most likely to be used without a
  120.     specific method call.  The description of the data fields are
  121.     as follows.
  122.  
  123.     -AbortDialog holds a pointer to the abort dialog when it valid.
  124.     It is valid only after a call to the method StartDoc and before
  125.     the call to the method EndDoc.
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.   PRODUCT  :  Turbo Pascal                           NUMBER  :  552
  141.   VERSION  :  1.0
  142.        OS  :  Windows
  143.      DATE  :  August 12, 1992                         PAGE  :  3/13
  144.  
  145.     TITLE  :  Unit for Printing in Windows
  146.  
  147.  
  148.  
  149.  
  150.     -AbortCallBackProc holds the address of the Abort Dialog's
  151.     callback function.  It's definition is found in the function
  152.     AbortCallBack in the implementation section of this unit.
  153.  
  154.     -SelectDialog is a pointer to the dialog used when selecting
  155.     the current printer. To be used when overriding the function of
  156.     the SelectPrinter method.
  157.  
  158.     -SelectInfo is the transfer record used in SelectDialog.  Holds
  159.     descriptions of all printers available and the currently
  160.     selected printer.
  161.  
  162.     -Driver, PrinterType, Port are null terminated strings holding
  163.     information relevant to the current printer.
  164.  
  165.     -DriverHandle is a handle to the library of the current printer
  166.     driver. It is setup in Init constructor and is freed in the
  167.     Done destructor.  It is used for setting up the DeviceMode
  168.     configuration call.
  169.  
  170.     -PrintDC is the device control established for printing. It is
  171.     created by the StartDoc method and valid until the EndDoc
  172.     method call. May be accessed directly or by the GetPrinterDC
  173.     method call.
  174.  
  175.     -Error holds the results of printer escape calls.  If an error
  176.     occurs, the result is placed here.  Is tested to determine if
  177.     further printing output is appropriate.
  178.  
  179.     -ExtDeviceMode holds the ExtDeviceMode procedure used for
  180.     retrieving, installing, and prompting for printing
  181.     configurations.
  182.  
  183.     -DeviceModeVar holds the DeviceMode procedure used for
  184.     prompting the user for printer configurations.
  185.  
  186.     For most programs, there is no need to access the data fields
  187.     of this object directly.  Call the appropriate method for the
  188.     operations detailed below.
  189.  
  190.     -Init retrieves the current printer configuration and sets up
  191.     the ExtDEviceMode and DeviceMode address from the current
  192.     printer's library.
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.   PRODUCT  :  Turbo Pascal                           NUMBER  :  552
  207.   VERSION  :  1.0
  208.        OS  :  Windows
  209.      DATE  :  August 12, 1992                         PAGE  :  4/13
  210.  
  211.     TITLE  :  Unit for Printing in Windows
  212.  
  213.  
  214.  
  215.  
  216.     -Done frees the library associated with the current printer.
  217.  
  218.     -SelectPrinter displays a printer select dialog permitting the
  219.     user to change the current printer information.
  220.  
  221.     -GetPrinterDC retrieves the device control associated with the
  222.     printer. Must be called after StartDoc.
  223.  
  224.     -DeviceMode calls the printer driver's DeviceMode routine.
  225.  
  226.     -BitMapCapable returns true if the current printing device can
  227.     handle bitmap graphics.
  228.  
  229.     -BandingRequired returns true if banding of bitmap images will
  230.     enhance printing speed.
  231.  
  232.     -StartDoc is called immediately before printing is to begin.
  233.     Establishes the device control.  Sets up the abort dialog and
  234.     sends the STARTDOC escape call.
  235.  
  236.     -NewFrame sends the NEWFRAME escape call and performs
  237.     appropriate error checking.
  238.  
  239.     -EndDoc sends the ENDDOC escape call and closes the Abort
  240.     Dialog if no errors have occurred.
  241.   }
  242.  
  243.   var
  244.     PrinterAbort: Boolean;
  245.   { Holds true when the user has aborted printing. }
  246.  
  247.   implementation
  248.  
  249.   const
  250.     id_ComboBox = 101;
  251.   { ID for the ComboBox used for Selecting the current printer }
  252.  
  253.   var
  254.     AbortWindow: HWnd;
  255.   { Window handle for the Abort Dialog.  It is used by the
  256.     AbortCallBackProc.}
  257.  
  258.   function GetItem(var S: PChar): PChar;
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.   PRODUCT  :  Turbo Pascal                           NUMBER  :  552
  273.   VERSION  :  1.0
  274.        OS  :  Windows
  275.      DATE  :  August 12, 1992                         PAGE  :  5/13
  276.  
  277.     TITLE  :  Unit for Printing in Windows
  278.  
  279.  
  280.  
  281.  
  282.   { Retrieves comma separated data from a null terminated string.
  283.     It returns the first data item and advances the pointer S to
  284.     the next data item in the string. }
  285.   var
  286.     P: PChar;
  287.     I: Integer;
  288.  
  289.   begin
  290.     I:=0;
  291.     while (S[I]<>',') and (S[I]<>#0) do
  292.       inc(I);
  293.     S[I]:=#0;
  294.     GetMem(P, Strlen(S)+1);
  295.     StrCopy(P,S);
  296.     GetItem:=P;
  297.                         I+1
  298.     if S[0]<>#0 then S:=   ;
  299.   end;
  300.  
  301.   procedure GetPrinterTypes(var PrinterTypes: PStrCollection);
  302.   { Retrieves all the device types from the WIN.INI and places this
  303.     information into the PStrCollection parameter.}
  304.   var
  305.     Buffer, BufferItem: PChar;
  306.     Item: PChar;
  307.     Count, I: Integer;
  308.  
  309.   begin
  310.     New(PrinterTypes, init(5,1));
  311.     GetMem(Buffer, 1024);
  312.     Count:=GetProfileString('devices', nil, ',,', Buffer, 1024);
  313.     BufferItem:=Buffer;
  314.     I:=0;
  315.     while I<Count do
  316.     begin
  317.       GetMem(Item, StrLen(BufferItem)+1);
  318.       StrCopy(Item, BufferItem);
  319.       PrinterTypes^.Insert(Item);
  320.       while (BufferItem[i]<>#0) and (I<Count) do
  321.         inc(I);
  322.       inc(I);
  323.       if BufferItem[I]=#0 then I:=Count;
  324.       if I<Count then
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.   PRODUCT  :  Turbo Pascal                           NUMBER  :  552
  339.   VERSION  :  1.0
  340.        OS  :  Windows
  341.      DATE  :  August 12, 1992                         PAGE  :  6/13
  342.  
  343.     TITLE  :  Unit for Printing in Windows
  344.  
  345.  
  346.  
  347.  
  348.       begin
  349.         BufferItem:=@ BufferItem[I];
  350.         Count:=Count-I;
  351.         I:=0;
  352.       end;
  353.     end;
  354.     FreeMem(Buffer, 1024);
  355.   end;
  356.  
  357.   procedure GetCurrentPrinter(var Driver, PrinterType,
  358.                               Port: PChar);
  359.   { Retrieves the current printing device information from the
  360.     WIN.INI file.}
  361.   var
  362.     ProfileInfo, CurrentItem: PChar;
  363.   begin
  364.     GetMem(ProfileInfo, 80+1);
  365.     GetProfileString('windows', 'device', ',,', ProfileInfo, 80);
  366.     CurrentItem:=ProfileInfo;
  367.     PrinterType:=GetItem(CurrentItem);
  368.     Driver:=GetItem(CurrentItem);
  369.     Port:=GetItem(CurrentItem);
  370.     FreeMem(ProfileInfo, 80+1);
  371.   end;
  372.  
  373.   procedure GetPrinter(PrinterType: PChar; var Driver,
  374.                        Port: PChar);
  375.   { Given a PrinterType string, this procedure returns the
  376.     appropriate driver and port information.}
  377.   var
  378.     ProfileInfo, CurrentItem: PChar;
  379.   begin
  380.     GetMem(ProfileInfo, 80+1);
  381.     GetProfileString('devices', PrinterType, ',', ProfileInfo, 80);
  382.     CurrentItem:=ProfileInfo;
  383.     Driver:=GetItem(CurrentItem);
  384.     Port:=GetItem(CurrentItem);
  385.   end;
  386.  
  387.   procedure TAbortDialog.SetUpWindow;
  388.   { Initializes PrinterAbort and AbortWindow. Then set the focus to
  389.     the AbortDialog.}
  390.   begin
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404.   PRODUCT  :  Turbo Pascal                           NUMBER  :  552
  405.   VERSION  :  1.0
  406.        OS  :  Windows
  407.      DATE  :  August 12, 1992                         PAGE  :  7/13
  408.  
  409.     TITLE  :  Unit for Printing in Windows
  410.  
  411.  
  412.  
  413.  
  414.     PrinterAbort:=false;
  415.     SetFocus(HWindow);
  416.     AbortWindow:=HWindow;
  417.   end;
  418.  
  419.   procedure TAbortDialog.WMCommand(var Msg: TMessage);
  420.   { If any command messages occur, a user abort has taken place.
  421.     Normally, this will include pressing ENTER, ESCAPE, the
  422.     SPACEBAR  or clicking the mouse on the Abort Dialog's Escape
  423.     button.}
  424.   begin
  425.     PrinterAbort:=true;
  426.   end;
  427.  
  428.   function AbortDlgProc(Dlg: HWnd; Message, WParam: Word;
  429.                         LParam:  LongInt) : Bool; export;
  430.   var
  431.     Result: Bool;
  432.   begin
  433.     case Message of
  434.       WM_INITDIALOG:
  435.       begin
  436.         PrinterAbort := False;
  437.         SetFocus(Dlg);
  438.         AbortWindow := Dlg;
  439.         Result :=true;
  440.       end;
  441.       WM_COMMAND:
  442.       begin
  443.         Result := true;
  444.       end;
  445.     else Result := false;
  446.     end;
  447.     AbortDlgProc := Result;
  448.   end;
  449.  
  450.   function AbortCallBack(DC: HDC; Code: Integer): Bool; export;
  451.   { While printing is taking place, checks to see if PrinterAbort
  452.     is true.  Otherwise messages are passed on.}
  453.   var
  454.     Msg: TMsg;
  455.   begin
  456.     while (not PrinterAbort) and
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.  
  467.  
  468.  
  469.  
  470.   PRODUCT  :  Turbo Pascal                           NUMBER  :  552
  471.   VERSION  :  1.0
  472.        OS  :  Windows
  473.      DATE  :  August 12, 1992                         PAGE  :  8/13
  474.  
  475.     TITLE  :  Unit for Printing in Windows
  476.  
  477.  
  478.  
  479.  
  480.           PeekMessage(Msg, 0, 0, 0, pm_Remove) do
  481.       if not IsDialogMessage(AbortWindow, Msg) then begin
  482.         TranslateMessage(Msg);
  483.         DispatchMessage(Msg);
  484.       end;
  485.     if PrinterAbort then AbortCallBack:=false
  486.     else AbortCallBack:=true;
  487.   end;
  488.  
  489.   constructor TPrinterInfo.Init;
  490.   { Gets the current printer information (Type, Driver, & Port) and
  491.     the printer types currently available.  Then retrieves the
  492.     ExtDeviceMode and DeviceModeVar address from the current
  493.     printer's library.}
  494.   var
  495.     I: Integer;
  496.     FullDriverName: PChar;
  497.     P: TFarProc;
  498.   begin
  499.     GetCurrentPrinter(Driver, PrinterType, Port);
  500.     for I:= 0 to StrLen(PrinterType) do
  501.       SelectInfo.Selection[I]:=PrinterType[I];
  502.     GetPrinterTypes(SelectInfo.Strings);
  503.  
  504.     GetMem(FullDriverName, 12+1);
  505.     StrLCat(StrCopy(FullDriverName, Driver), '.DRV', 12);
  506.     DriverHandle:=LoadLibrary(FullDriverName);
  507.     FreeMem(FullDriverName, 12+1);
  508.  
  509.     P:=GetProcAddress(DriverHandle, 'ExtDeviceMode');
  510.     ExtDeviceMode:=TExtDeviceMode(P);
  511.     P:=GetProcAddress(DriverHandle, 'DeviceMode');
  512.     DeviceModeVar:=TDeviceMode(P);
  513.     PrintDC:=0;
  514.   end;
  515.  
  516.   destructor TPrinterInfo.Done;
  517.   { Frees up the library taken in the constructor Init.}
  518.   begin
  519.     FreeLibrary(DriverHandle);
  520.   end;
  521.  
  522.   procedure TPrinterInfo.SelectPrinter;
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533.  
  534.  
  535.  
  536.   PRODUCT  :  Turbo Pascal                           NUMBER  :  552
  537.   VERSION  :  1.0
  538.        OS  :  Windows
  539.      DATE  :  August 12, 1992                         PAGE  :  9/13
  540.  
  541.     TITLE  :  Unit for Printing in Windows
  542.  
  543.  
  544.  
  545.  
  546.   { Displays a Printer Select dialog called PISELECT and changes
  547.     the current printer information as is done in Init.}
  548.   var
  549.     FullDriverName: PChar;
  550.     P: TFarProc;
  551.     ComboBox: PComboBox;
  552.   begin
  553.     new(SelectDialog, Init(Nil, 'PISELECT'));
  554.     New(ComboBox, InitResource(SelectDialog, id_ComboBox, 80));
  555.     SelectDialog^.TransferBuffer:=@ SelectInfo;
  556.     if Application^.ExecDialog(SelectDialog) = id_Ok then
  557.     begin
  558.       FreeLibrary(DriverHandle);
  559.       if PrintDC<>0 then DeleteDC(PrintDC);
  560.       FreeMem(PrinterType, StrLen(PrinterType)+1);
  561.       GetMem(PrinterType, StrLen(@ SelectInfo.Selection)+1);
  562.  
  563.       StrCopy(PrinterType, @ SelectInfo.Selection);
  564.  
  565.       FreeMem(Driver, StrLen(Driver)+1);
  566.       FreeMem(Port, StrLen(Port)+1);
  567.       GetPrinter(PrinterType, Driver, Port);
  568.  
  569.       GetMem(FullDriverName, 12+1);
  570.       StrLCat(StrCopy(FullDriverName, Driver), '.DRV', 12);
  571.       DriverHandle:=LoadLibrary(FullDriverName);
  572.       FreeMem(FullDriverName, 12+1);
  573.  
  574.       P:=GetProcAddress(DriverHandle, 'ExtDeviceMode');
  575.       ExtDeviceMode:=TExtDeviceMode(P);
  576.       P:=GetProcAddress(DriverHandle, 'DeviceMode');
  577.       DeviceModeVar:=TDeviceMode(P);
  578.     end;
  579.   end;
  580.  
  581.   function TPrinterInfo.GetPrinterDC: HDC;
  582.   { Retrieves the Device control associated with the printer.  May
  583.     only be called after a call to the StartDoc method. }
  584.   begin
  585.     GetPrinterDC:=PrintDC;
  586.   end;
  587.  
  588.   var Parent: PWindowsObject;
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600.  
  601.  
  602.   PRODUCT  :  Turbo Pascal                           NUMBER  :  552
  603.   VERSION  :  1.0
  604.        OS  :  Windows
  605.      DATE  :  August 12, 1992                        PAGE  :  10/13
  606.  
  607.     TITLE  :  Unit for Printing in Windows
  608.  
  609.  
  610.  
  611.  
  612.   procedure TPrinterInfo.StartDoc(Name: PChar; AbortBox: Boolean);
  613.   { Called immediately before printing is to begin.  Establishes
  614.     the device control.  Sets up the Abort Dialog. And send the
  615.     STARTDOC escape call.}
  616.   var
  617.     AbortProc: TFarProc;
  618.   begin
  619.     Error:=0;
  620.     PrintDC:=CreateDC(Driver, PrinterType, Port, nil);
  621.     if LowMemory  then
  622.       AbortBox := false
  623.     else
  624.     if AbortBox then
  625.     begin
  626.   (*
  627.       new(AbortDialog, Init(Application^.MainWindow, 'PIABORT'));
  628.       AbortDialog^.Create;
  629.   *)
  630.       AbortProc := MakeProcInstance(@ AbortDlgProc, HInstance);
  631.       AbortDlg := CreateDialog(HInstance, 'PIABORT',
  632.                                GetFocus, AbortProc);
  633.     end
  634.     else
  635.       AbortDialog := Nil;
  636.     if AbortBox then
  637.     begin
  638.       AbortCallBackProc:=MakeProcInstance(@ AbortCallBack,
  639.                                           HInstance);
  640.       Escape(PrintDC, SETABORTPROC, 0, AbortCallBackProc, nil);
  641.     end;
  642.     RasterCaps:=GetDeviceCaps(PrintDC, WINTYPES.RASTERCAPS);
  643.     Error:=Escape(PrintDC, WINTYPES.STARTDOC, StrLen(Name),
  644.                   Name, nil);
  645.   end;
  646.  
  647.   procedure TPrinterInfo.NewFrame;
  648.   { Sends the NEWFRAME escape call and performs appropriate error
  649.     checking.}
  650.   begin
  651.     if Error>=0 then
  652.       Error:=Escape(PrintDC, WINTYPES.NEWFRAME, 0, nil, nil);
  653.     if Error<0 then
  654.       case Error of
  655.  
  656.  
  657.  
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.  
  665.  
  666.  
  667.  
  668.   PRODUCT  :  Turbo Pascal                           NUMBER  :  552
  669.   VERSION  :  1.0
  670.        OS  :  Windows
  671.      DATE  :  August 12, 1992                        PAGE  :  11/13
  672.  
  673.     TITLE  :  Unit for Printing in Windows
  674.  
  675.  
  676.  
  677.  
  678.         SP_ERROR: MessageBox(GetFocus,
  679.           'General Printer Error', nil, mb_Ok or mb_IconStop);
  680.         SP_OUTOFDISK: MessageBox(GetFocus,
  681.           'No disk space for spooling', nil, mb_Ok or mb_IconStop);
  682.         SP_OUTOFMEMORY: MessageBox(GetFocus,
  683.           'No memory space for spooling', nil,
  684.           mb_Ok or mb_IconStop);
  685.         SP_USERABORT: MessageBox(GetFocus,
  686.           'Printing Terminated by User', nil,
  687.           mb_Ok or mb_IconStop);
  688.       else
  689.         MessageBox(GetFocus,
  690.           'Printing Halted', nil, mb_OK or mb_IconStop);
  691.       end;
  692.   end;
  693.  
  694.   procedure TPrinterInfo.NextBand(var R:TRect);
  695.   { When Bitmap banding is required, this routine returns the next
  696.     rectangular region to be printed.  This method is not required
  697.     but can speed up printing bitmaps.}
  698.   begin
  699.     if Error>=0 then
  700.       Error:=Escape(PrintDC, WINTYPES.NEXTBAND, 0, nil, @R);
  701.     if Error<0 then
  702.       case Error of
  703.         SP_ERROR: MessageBox(GetFocus,
  704.           'General Printer Error', nil, mb_Ok or mb_IconStop);
  705.         SP_OUTOFDISK: MessageBox(GetFocus,
  706.           'No disk space for spooling', nil, mb_Ok or mb_IconStop);
  707.         SP_OUTOFMEMORY: MessageBox(GetFocus,
  708.           'No memory space for spooling', nil,
  709.           mb_Ok or mb_IconStop);
  710.         SP_USERABORT: MessageBox(GetFocus,
  711.           'Printing Terminated by User', nil,
  712.           mb_Ok or mb_IconStop);
  713.       else
  714.         MessageBox(GetFocus,
  715.           'Printing Halted', nil, mb_OK or mb_IconStop);
  716.       end;
  717.   end;
  718.  
  719.   procedure TPrinterInfo.EndDoc;
  720.   { Sends the ENDDOC escape call and closes the Abort Dialog if no
  721.  
  722.  
  723.  
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730.  
  731.  
  732.  
  733.  
  734.   PRODUCT  :  Turbo Pascal                           NUMBER  :  552
  735.   VERSION  :  1.0
  736.        OS  :  Windows
  737.      DATE  :  August 12, 1992                        PAGE  :  12/13
  738.  
  739.     TITLE  :  Unit for Printing in Windows
  740.  
  741.  
  742.  
  743.  
  744.      errors have occurred.}
  745.   begin
  746.     if Error>=0 then
  747.       Error:=Escape(PrintDC, WINTYPES.ENDDOC, 0, nil, nil);
  748.     if Error>=0 then
  749.     begin
  750.       DeleteDC(PrintDC);
  751.       if AbortDlg <> 0 then
  752.   (*
  753.        AbortDialog^.CloseWindow;
  754.   *)
  755.        DestroyWindow(AbortDlg);
  756.     end;
  757.   end;
  758.  
  759.   procedure TPrinterInfo.DeviceMode;
  760.   { Calls the printer driver's DeviceMode routine.  Normally
  761.     displays a dialog allowing the user to change the printer's
  762.     configuration.}
  763.   begin
  764.       DeviceModeVar(GetFocus,
  765.                     DriverHandle, PrinterType, Port);
  766.   end;
  767.  
  768.   function TPrinterInfo.BitMapCapable: boolean;
  769.   { Returns true if the current printing device can handle bitmap
  770.     graphics.}
  771.   begin
  772.     BitMapCapable:=(RasterCaps and RC_BITBLT)<>0;
  773.   end;
  774.  
  775.   function TPrinterInfo.BandingRequired: boolean;
  776.   { Returns true if banding of bitmap images will enhance printing
  777.     speed.}
  778.   begin
  779.     BandingRequired:=(RasterCaps and RC_BANDING)<>0;
  780.   end;
  781.  
  782.   end.
  783.  
  784.   { Here is the descriptions of the dialogs PIABORT and PISELECT
  785.     found in the resources file PRINTER.RES
  786.  
  787.  
  788.  
  789.  
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796.  
  797.  
  798.  
  799.  
  800.   PRODUCT  :  Turbo Pascal                           NUMBER  :  552
  801.   VERSION  :  1.0
  802.        OS  :  Windows
  803.      DATE  :  August 12, 1992                        PAGE  :  13/13
  804.  
  805.     TITLE  :  Unit for Printing in Windows
  806.  
  807.  
  808.  
  809.  
  810.   PIABORT DIALOG DISCARDABLE LOADONCALL PURE MOVEABLE 44, 46, 175,
  811.   78
  812.   STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | 0x80L
  813.   CAPTION "Printing in Progress"
  814.   BEGIN
  815.     CONTROL "Press Escape to Halt Printing" 101, "STATIC", WS_CHILD
  816.   |
  817.       WS_VISIBLE, 37, 17, 98, 12
  818.     CONTROL "Escape" 102, "BUTTON", WS_CHILD | WS_VISIBLE |
  819.   WS_TABSTOP,
  820.       73, 49, 40, 13
  821.   END
  822.  
  823.   PISELECT DIALOG DISCARDABLE LOADONCALL PURE MOVEABLE 44, 37, 145,
  824.   85
  825.   STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | 0x80L
  826.   CAPTION "Select Printer"
  827.   BEGIN
  828.     CONTROL "COMBOBOX" 101, "COMBOBOX", WS_CHILD | WS_VISIBLE |
  829.   WS_VSCROLL |
  830.       0x101L, 26, 11, 84, 43
  831.     CONTROL "Ok" 1, "BUTTON", WS_CHILD | WS_VISIBLE | WS_TABSTOP,
  832.       29, 61, 40, 12
  833.     CONTROL "Cancel" 2, "BUTTON", WS_CHILD | WS_VISIBLE |
  834.   WS_TABSTOP,
  835.       86, 61, 40, 12
  836.   END
  837.   }
  838.  
  839.   DISCLAIMER: You have the right to use this technical information
  840.   subject to the terms of the No-Nonsense License Statement that
  841.   you received with the Borland product to which this information
  842.   pertains.
  843.  
  844.  
  845.  
  846.  
  847.  
  848.  
  849.  
  850.  
  851.  
  852.  
  853.  
  854.  
  855.  
  856.  
  857.  
  858.  
  859.